require('dotenv').config();
const { startScheduler } = require("../utils/scheduler")
const mongoose = require("mongoose");
module.exports = () => {
    mongoose
        .connect(process.env.NODE_ENV === 'production' ? process.env.PRODUCTION_DB_URL : process.env.DEVELOPMENT_DB_URL)
        .then(async () => {
            console.log(`${process.env.NODE_ENV === 'production' ? '线上' : '本地'}数据库连接成功`);
            startScheduler()
        })
        .catch((err) => {
            console.log(`${process.env.NODE_ENV === 'production' ? '线上' : '本地'}数据库连接失败`, err);
        });
}

